package RuiGe;

import java.util.Scanner;

public class Demo5 {

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        char[][] arr=new char[n+2][m+2];
        for(int i=0;i<n+2;i++){
            for(int j=0;j<m+2;j++){
                arr[i][j]='?';
            }
        }
        for(int i=1;i<=n;i++){
            String sTmp=sc.next();
            char[] charArray = sTmp.toCharArray();
            int k=0;
            for(int j=1;j<=m;j++){
                arr[i][j]=charArray[k++];
            }
        }

        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(arr[i][j]=='?'){
                    //判断四周
                    int count=0;
                    for(int k=j-1;k<=j+1;k++){
                        if(arr[i-1][k]=='*'){
                            count++;
                        }
                    }
                    if(arr[i][j-1]=='*'){
                        count++;
                    }
                    if(arr[i][j+1]=='*'){
                        count++;
                    }
                    for(int k=j-1;k<=j+1;k++){
                        if(arr[i+1][k]=='*'){
                            count++;
                        }
                    }
                    arr[i][j]= (char) (count+'0');
                }
            }
        }

        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                System.out.print(arr[i][j]);
            }
            System.out.println();
        }

    }
}
